module windump.plugins.sysinfo.sysinfo;

version(none) {

import std.c.windows.windows;
import std.string;

import windump.wdversion;
import windump.scanning.detector;
import windump.utf;
import windump.w32api;

//W32 APIs:


class SysInfoDetector : Detector!(SysInfoDetector, "system/sysinfo", "table")
{
    public this()
    {
    }

    public override XmlElement update()
    {
        auto ele = new XmlElement("sysinfo");

        ele.setAttribute("WindumpVersion", WindumpVersion);

		SYSTEMTIME time;
		GetLocalTime(&time);
		string timestr = format("%d/%d/%d %d:%d:%d", time.wMonth, time.wDay, time.wYear, 
				time.wHour, time.wMinute, time.wSecond);

        ele.setAttribute("ScanTimeStame", timestr);

		wchar[MAX_PATH] wstr;
		uint wlen = MAX_PATH;

		GetUserNameW(wstr.ptr, &wlen);
		ele.setAttribute("UserName", toUtf8(wstr[0..wlen - 1]));

		wlen = MAX_PATH;
		GetComputerNameW(wstr.ptr, &wlen);
		ele.setAttribute("ComputerName", toUtf8(wstr[0..wlen - 1]));

        return ele;
    }
}

}
